class ImagesController < ApplicationController

  def view
   @image = Image.find(params[:id])
   
   @size = params[:size] if  !params[:size].nil?  and  Image.possible_sizes.key? params[:size]
  end
  
  # To get the url of an image an id is neccesarym in the case of image type dragable objects
  # rails passes the id property of the html element, it is picture_OBJECT_ID
  # then if the parameter[:id] matches this pattern, the string is filtered to get the integer
  def get_url
    id = params[:id]
    if id =~ /image_(\d)+/   
      id = id.strip
      id = id.gsub('image_','') 
    end
    id = (id.to_f).to_i
    begin  
      @image = Image.find(id)
    rescue Exception => e
      @image_error = e.message
    end
    
  end
  
  # Get image metadata using magic
  def get_image_metadata
  end
  
end
